using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class LevelController : MonoBehaviour
{
    public int starsNum = 0;
    public bool CanSelect = false;
    public GameObject Levellock;
    public GameObject LevelStars;
    public GameObject panel;
    public GameObject Menu;
    public TextMeshProUGUI starText;
    public int startnum =1;
    public int endnum =3;
    // Start is called before the first frame update
    void Start()
    {
        if (PlayerPrefs.GetInt("TotalNum", 0) >= starsNum)
        {
            CanSelect = true;
        }
        if(CanSelect)
        {
            Levellock.SetActive(false);
            LevelStars.SetActive(true);
        }
        int count = 0;
        for (int i = startnum; i < endnum; i++)
        {
            count += PlayerPrefs.GetInt("level" + i.ToString(), 0);
        }
        starText.text = count.ToString() + "/" + starsNum;
    }

    public void Select()
    {
        if(CanSelect)
        {
            Menu.SetActive(false);
            panel.SetActive(true);
        }
    }

    public void BackMenu()
    {
        Menu.SetActive(true);
        panel.SetActive(false);
    }
}
